package com.devo.icecream.ui.widget

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.devo.icecream.ui.theme.Grey
import com.devo.icecream.ui.theme.Main
import com.devo.icecream.ui.theme.textGreyColor

@Composable
fun AppButton(
    modifier: Modifier = Modifier,
    text: String = "立即制作",
    enable: Boolean = true,
    onClick: () -> Unit = {}
) {

    val buttonColors = ButtonDefaults.buttonColors(
        backgroundColor = Main.copy(alpha = 0.1f),
        contentColor = Main,
        disabledContentColor = textGreyColor,
        disabledBackgroundColor = Grey
    )
    TextButton(
        interactionSource = remember { MutableInteractionSource()},
        modifier = Modifier.then(modifier),
        shape = RoundedCornerShape(8.dp),
        colors = buttonColors,
        border = BorderStroke(1.dp, buttonColors.contentColor(enabled = enable).value),
        contentPadding = PaddingValues(18.dp, 12.dp),
        enabled = enable,
        onClick = { onClick() }
    ) {
        Text(
            text = text,
            style = MaterialTheme.typography.h3.copy(color = buttonColors.contentColor(enabled = enable).value)
        )

    }

}